// 对象
let person:{name:string,age:number,sex?:string}
person = {
    name:"SunWuKong",
    age:26,
    sex:"male"
}


let person3:{name:string} & {age:number}
person3 = {
    name:"TangSeng",
    age:18
}

let person1:{name:string,[propName:string]:any}

person1 = {
    name:"BaJie",
    age:26,
    sex:"male"
}

// 定义枚举
enum Gender {Male,Female}
// 使用枚举
let obj:{name:string,gender:Gender}
obj = {name:"SunWuKong",gender:Gender.Male}
console.log(obj);
console.log(obj.gender == Gender.Male);

let male = Gender[0]
let female = Gender[1]
console.log(male,female);

// 手动赋值1
enum  Animal {Dog = 1, Cat, Sheep}
let cat:Animal = Animal.Cat
console.log(cat);

// 手动赋值2
enum Color {Red = 1, Green = 2, Blue = 4}
let color1:Color = Color.Green;
let color2:string = Color[4];
console.log(color1);
console.log(color2);

// 字面量
let number:10;
number = 10;
number = 11;

// 联合类型
let sex:"male" | "female";
sex = "male" // 正确
sex = "hello" // 错误

// any
let param1;

// unknow
let param2:unknown;
param2 = "hello"
console.log(param2.length);

(param2 as string).length


